Skip to content

Conversation

@xterao
Copy link
Collaborator

@xterao xterao commented May 30, 2025

When invoking a method on a field-access element that already has a different variable name set in its argument parameter, subsequent suggestions for instance fields and methods were not shown.

The issue occurred because, when collecting the list of elements before the caret, children of the argument-parameter element were incorrectly treated as part of the field-access chain, resulting in an invalid property-access structure.

This update filters out any elements whose parent is the argument-parameter class when gathering preceding elements, so that only the correct elements are retrieved for suggestions.

@xterao xterao self-assigned this May 30, 2025
@xterao xterao added the bug Something isn't working label May 30, 2025
@github-actions github-actions bot added the fix Bug fixes label May 30, 2025
@xterao xterao linked an issue May 30, 2025 that may be closed by this pull request
@xterao xterao added this to the 0.8.1 Release milestone May 30, 2025
@xterao xterao requested a review from Copilot May 30, 2025 01:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses a bug in code completion where subsequent instance field and method suggestions were missing due to incorrect element collection prior to the caret position. Key changes include filtering out argument-parameter child elements during completion, new test files covering method parameter use cases, and refactoring of PSI element helper methods to support the updated logic.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
completePropertyAfterStaticPropertyCallWithMethodParameter.sql Adds test case to verify completion after a static property call with a method parameter.
completeParameterFirstPropertyWithMethodParameter.sql Introduces a test for parameter-first property completion using a method parameter.
completeInstancePropertyWithMethodParameter.sql Adds a test verifying instance property completion with a method parameter.
completeDirectiveInsideForWithMethodParameter.sql Enhances directive completion tests for for-loop constructs with method parameters.
completeDirectiveFieldInsideIfWithMethodParameter.sql Adds tests to check directive completion inside if conditions with method parameters.
ProjectDetail.java Introduces a new static method getProject(String) to retrieve a project from a subProjects list.
SqlCompleteTestDao.java Declares new DAO methods to support the updated code completion scenarios.
SqlCompleteTest.kt Updates test harness to include newly added SQL test files and validates various completion scenarios.
PsiElementExtension.kt Removes an outdated helper function and adds a new utility for symbol identification.
SqlParameterCompletionProvider.kt Refactors completion provider to remove legacy helper usage and introduce a new findSelfBlocks helper.

@xterao xterao force-pushed the fix/code-completion-fails branch from 193cede to fe4d8c4 Compare May 30, 2025 01:14
@xterao xterao merged commit dd18e42 into main May 30, 2025
5 checks passed
@xterao xterao deleted the fix/code-completion-fails branch May 30, 2025 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fix Bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code completion fails after existing values in method arguments

2 participants